clear all
set more off

use  "dta/data", clear

// create variable dist_graph_2 for different bins of 2 kms
g tmp0 = abs(dist) 
replace tmp0 = tmp0 -1 if french == 0
g tmp = tmp0 / 2
g tmp2 = int(tmp)
g dist_graph_2 = tmp2*2
replace dist_graph_2 = (dist_graph_2 *-1) -2 if french == 0 
drop tmp0
drop tmp
drop tmp2

global xpop "population foreigners young old"
global xeco "secondary tertiary agglo center dist_center tourist"
global xgeo "altitude_min altitude altitude_max area"
global xamen "lake castle wealthtax1940"

g border = (dist >=-20 & dist <= 20)
g int_bfr = border * french


// mean-deviation

foreach var of varlist $xpop $xeco $xgeo $xamen{
qui: sum `var' if (dist >=-40 & dist <= 40)
local m = r(mean)
g md_`var' = `var'-`m'
g fr_md_`var' = french*md_`var'
g bor_md_`var' = border*md_`var'
}

global xmdpop "md_population md_foreigners md_young md_old"
global xmdeco "md_secondary md_tertiary md_agglo md_center md_dist_center md_tourist"
global xmdgeo "md_altitude_min md_altitude md_altitude_max md_area"
global xmdamen "md_lake md_castle md_wealthtax1940"

global xintpop "fr_md_population fr_md_foreigners fr_md_young fr_md_old bor_md_population bor_md_foreigners bor_md_young bor_md_old"
global xinteco "fr_md_secondary fr_md_tertiary fr_md_agglo fr_md_center fr_md_dist_center fr_md_tourist bor_md_secondary bor_md_tertiary bor_md_agglo bor_md_center bor_md_dist_center bor_md_tourist"
global xintgeo "fr_md_altitude_min fr_md_altitude fr_md_altitude_max fr_md_area bor_md_altitude_min bor_md_altitude bor_md_altitude_max bor_md_area"
global xintamen "fr_md_lake fr_md_castle fr_md_wealthtax1940 bor_md_lake bor_md_castle bor_md_wealthtax1940"

sum year
global y_max = r(max)
global y_min = r(min)
global y_count = ($y_max - $y_min)+1

* ============================================
* = Figure 2 : preferences =
* ============================================

local nb_year $y_count
foreach var in pref_left{
preserve
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) ylabel(30(5)55, labsize(vsmall)) ytitle("vote shares", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+55 -25 "German", place(c) size(medsmall)) text(+55 25 "French", place(c) size(medsmall)) text(+26 0 "(37 referenda)", place(c) size(small))
graph export figures/fig2.eps , replace
restore
}


* ============================================
* = Figure 3: tax rates =
* ============================================

local nb_year $y_count
foreach var in md_taxmult{
preserve
drop if `var' == .
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black)  yscale(range(-1.25 1)) ylabel(-1(0.5)1, labsize(vsmall)) ytitle("standardized tax multipliers", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+1 -25 "German", place(c) size(medsmall)) text(+1 25 "French", place(c) size(medsmall))
graph export figures/fig3.eps , replace
restore
}



* ============================================
* = Figure 6 (a) - Preferences =
* ============================================

xi: reg pref_left $xmdgeo $xmdamen $xmdpop $xmdeco $xintgeo $xintamen $xintpop $xinteco  i.year
predict res_P, residuals

local nb_year $y_count
foreach var in res_P{
preserve
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) || lfit ma_`var' dist if dist<0, lpattern(dash) lc(gray) || lfit ma_`var' dist if dist>=0,  lpattern(dash) lc(gray) yscale(range(-5 7)) ylabel(-5(2)6, labsize(vsmall)) ytitle("residuals", size(small)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(small)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(small)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+6 -25 "German", place(c) size(medsmall)) text(+6 25 "French", place(c) size(medsmall)) text(-6.75 0 "(37 referenda)", place(c) size(small))
graph export figures/fig6a.eps , replace
restore
}
cap drop res

* ============================================
* = Figure 6 (b) - Tax rates =
* ============================================

xi: reg md_taxmult $xmdgeo $xmdamen $xmdpop $xmdeco $xintgeo $xintamen $xintpop $xinteco  i.year
predict res_T, residuals

local nb_year $y_count
foreach var in res{
preserve
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0, lc(black) || lfit ma_`var' dist if dist<0, lpattern(dash) lc(gray) || lfit ma_`var' dist if dist>=0,  lpattern(dash) lc(gray) yscale(range(-1.25 1)) ylabel(-1(0.5)1, labsize(vsmall)) ytitle("residuals", size(small)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(small)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(small)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+1 -25 "German", place(c) size(medsmall)) text(+1 25 "French", place(c) size(medsmall))
graph export figures/fig6b.eps, replace
restore
}
cap drop res


* ============================================
* = Figure A.1 =
* ============================================

*** 1970(1980)-1989
preserve
keep if year >= 1980 & year < 1990
local nb_year 10

foreach var in pref_left_1980{
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) ylabel(20(5)45, labsize(vsmall)) ytitle("vote shares", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+45 -25 "German", place(c) size(medsmall)) text(+45 25 "French", place(c) size(medsmall)) text(+46 0 "(1981-1989)", place(c) size(small)) text(16 0 "(3 referenda)", place(c) size(small))
graph export figures/figA1a.eps , replace
}
restore

preserve
keep if year >= 1970 & year < 1990
local nb_year 20
foreach var in md_taxmult{
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) yscale(range(-1.25 1.5)) ylabel(-1(0.5)1.5, labsize(vsmall)) ytitle("standardized tax multipliers", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+1.5 -25 "German", place(c) size(medsmall)) text(+1.5 25 "French", place(c) size(medsmall)) text(+1.6 0 "(1970-1989)", place(c) size(small))
graph export figures/figA1d.eps , replace
}
restore

*** 1990-1999
preserve
keep if year >= 1990 & year < 2000
local nb_year 10
foreach var in pref_left_1990{
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) ylabel(30(5)55, labsize(vsmall)) ytitle("vote shares", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+55 -25 "German", place(c) size(medsmall)) text(+55 25 "French", place(c) size(medsmall)) text(+56 0 "(1990-1999)", place(c) size(small)) text(+26 0 "(11 referenda)", place(c) size(small))
graph export figures/figA1b.eps , replace
}
restore

preserve
keep if year >= 1990 & year < 2000
local nb_year 10
foreach var in md_taxmult{
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) yscale(range(-1.25 1.5)) ylabel(-1(0.5)1.5, labsize(vsmall)) ytitle("standardized tax multipliers", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+1.5 -25 "German", place(c) size(medsmall)) text(+1.5 25 "French", place(c) size(medsmall)) text(+1.6 0 "(1990-1999)", place(c) size(small))
graph export figures/figA1e.eps , replace
}
restore

*** 2000-2011
preserve
keep if year >=2000
local nb_year 12 
foreach var in pref_left_2000{
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) ylabel(30(5)55, labsize(vsmall)) ytitle("vote shares", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+55 -25 "German", place(c) size(medsmall)) text(+55 25 "French", place(c) size(medsmall)) text(+56 0 "(2000-2011)", place(c) size(small)) text(+26 0 "(23 referenda)", place(c) size(small))
graph export figures/figA1c.eps , replace
}
restore

preserve
keep if year >=2000
local nb_year 12 
foreach var in md_taxmult{
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0,  lc(black) yscale(range(-1.25 1.5)) ylabel(-1(0.5)1.5, labsize(vsmall)) ytitle("standardized tax multipliers", size(medsmall)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(medsmall)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(medsmall)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+1.5 -25 "German", place(c) size(medsmall)) text(+1.5 25 "French", place(c) size(medsmall)) text(+1.6 0 "(2000-2011)", place(c) size(small))
graph export figures/figA1f.eps , replace
}
restore


* ============================================
* = Figure A2 - Median income =
* ============================================
replace medinc = medinc*1000
xi: reg medinc french border $xmdgeo $xmdamen $xmdpop $xmdeco $xintgeo $xintamen $xintpop $xinteco  i.year
predict res_T, residuals

local nb_year $y_count
foreach var in res{
preserve
drop if `var'==.
collapse `var' (sd) sd = `var' (count) no = `var', by(dist_graph_2)
replace no = no/`nb_year'
gen ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]+no[_n+2])
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == -4
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == -2
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 0
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == 2
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1])/(no[_n-2]+no[_n-1]+no[_n]+no[_n+1]) if dist_graph_2 == 42
replace ma_`var' = (`var'[_n-2]*no[_n-2]+`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n])/(no[_n-2]+no[_n-1]+no[_n]) if dist_graph_2 == 44
replace ma_`var' = (`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -44
replace ma_`var' = (`var'[_n-1]*no[_n-1]+`var'[_n]*no[_n]+`var'[_n+1]*no[_n+1]+`var'[_n+2]*no[_n+2])/(no[_n-1]+no[_n]+no[_n+1]+no[_n+2]) if dist_graph_2 == -42
keep if dist >=-40 & dist <= 40
tw scatter `var' dist if dist<0, mc(black) msize(vsmall) || scatter `var' dist if dist>=0, mc(black) msize(vsmall)|| line ma_`var' dist if dist<0, lc(black) || line ma_`var' dist if dist>=0, lc(black) || lfit ma_`var' dist if dist<0, lpattern(dash) lc(gray) || lfit ma_`var' dist if dist>=0,  lpattern(dash) lc(gray) yscale(range(-5000 5000)) ylabel(-5000(2500)5000, labsize(vsmall)) ytitle("residuals", size(small)) xline(0, lp("-") lc(black)) legend(off) xlabel(-40(10)40, labsize(vsmall)) xtitle("road distance to language border", size(small)) || spike no dist , lw(vthin) blcolor(black) yaxis(2) ytitle("number of municipalities", axis(2) size(small)) ysca(axis(2) r(0 100)) ylabel(0(10)50, labsize(vsmall) axis(2)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) text(+1 -25 "German", place(c) size(medsmall)) text(+1 25 "French", place(c) size(medsmall))
graph export figures/figA2.eps, replace
restore
}
cap drop res

